package com.haoze.nurse.enumeration;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

public class PatientCardFilterEnum {
    private String enumValue;
    private String enumName;
    private final static Map<String, PatientCardFilterEnum> enumMap = new HashMap();

    /**
     * 全部类型病人卡片
     */
    public final static PatientCardFilterEnum All = new PatientCardFilterEnum("0","全部类型");
    /**
     * 特级护理
     */
    public final static PatientCardFilterEnum Special  = new PatientCardFilterEnum("1","特级护理");
    /**
     * 一级护理
     */
    public final static PatientCardFilterEnum CareA = new PatientCardFilterEnum("2","一级护理");
    /**
     * 二级护理
     */
    public final static PatientCardFilterEnum CareB = new PatientCardFilterEnum("3","二级护理");
    /**
     * 三级护理
     */
    public final static PatientCardFilterEnum CareC  = new PatientCardFilterEnum("4","三级护理");
    /**
     * 病危
     */
    public final static PatientCardFilterEnum SickSevereVery = new PatientCardFilterEnum("5","病危");
    /**
     * 病重
     */
    public final static PatientCardFilterEnum SickSevere = new PatientCardFilterEnum("6","病重");
    /**
     * 新入院
     */
    public final static PatientCardFilterEnum NewIn = new PatientCardFilterEnum("7","新入院");
    /**
     * 新医嘱
     */
    public final static PatientCardFilterEnum NewOrder = new PatientCardFilterEnum("8","新医嘱");

    private PatientCardFilterEnum(String enumValue, String enumName){
        this.enumValue = enumValue;
        this.enumName = enumName;
    }

    public static PatientCardFilterEnum fromValue(String enumValue){
        if(enumMap.size() == 0) {
            putSourceEnum();
        }
        return enumMap.get(enumValue);
    }

    private static void  putSourceEnum(){

        Class clazz = PatientCardFilterEnum.class;
        Field[] fields = clazz.getDeclaredFields();
        PatientCardFilterEnum enumClass = null;
        for(Field field : fields) {
            if(field.getType().equals(clazz)) {
                try {
                    enumClass = (PatientCardFilterEnum)field.get(null);
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
                if(enumClass != null) {
                    enumMap.put(enumClass.getEnumValue(),enumClass);
                }
            }
        }
    }

    public String getEnumValue() {
        return enumValue;
    }

    public String getEnumName() {
        return enumName;
    }
}
